1 Bevezetés

A feladat során fel kellett tennünk egy kérdést, adatot kellett keresnünk és felderítő elemzést végezni.

A záró projektemben a lépések megfordultak, és először adatokat találtam, majd utána tettem fel egy kérdést és kezdtem el a felderítő elemzést.

Először egy predikciós modellben gondolkodtam, ami meghatározná a várható éjszaka/fő árat, de az adatok megismerése közben inkább afelé húzott a kíváncsiság, mitől függ, hogy az a szállás éppen üres? Meg lehet jósolni, hogy milyen paraméterek adnak jó esélyt arra, hogy magas legyen a kihasználtság?

Tehát a végső kérdésem a következő:

Milyen összefüggéseket figyelhetünk meg a madridi Airbnb-k foglalási arányában?

Eredetileg egy rövid predikciót is terveztem amivel előre lehetne jelezni a következő havi foglaltságot, de sajnos ezt az adatok - az én képességeim szintjén - nem igazán tették lehetővé.

A projekt két nagyobb részből áll. Az első részben megpróbálom megbecsülni egy-egy szálláshely havi foglalásainak a számát, a második részben pedig a lehetséges összefüggéseket mutatom be néhány leíró statisztikával.

Az adatbázis - mint ahogy azt az elsődleges leíró statisztikáknál is megemlítem - viszonylag nagy és rengeteg elemzési lehetőséget nyer. A feladat megoldása során igyekeztem egy kisebb részre koncantrálni, hogy ne vesszek el, de ugyanakkor olyan eszközöket haszálni amiket az órán tanultunk.

2 Adatok forrása és rövid háttere

Az adatokat ehhez a projekthez közvetlenül Kaggle-ről töltöttem le az alábbielérhetőségen: https://www.kaggle.com/rusiano/madrid-airbnb-data

Az adatbázis készítője ebben a formátumban az Inside Airbnb projekt. Az Inside Airbnb az Airbnb oldalon elérhető publikus adatokat gyűjti és elemzi, jelenleg több mint 50 városról tekinthetünk meg interakítv térképeket.

Madridról a következő interaktív térkép elérhető: http://insideairbnb.com/madrid

Mivel az adatok nyilvánosak és néhány városban akár havonta tesznek közzé új scrape-t, egy rövid időre felmerült bennem másik város, mint Madrid elemzése - így ha fura eredmények jönnek ki, könnyebben tudom magyarázni helyismeret segítségével. Az egyik város Budapest lett volna, de itt pont nincs összegyűjtött adat. A másik város Tokió, de ott feleannyi listázásról volt információ és nagyon egyenlőtlenül szóródtak a helyszínek, ezért azt is elvetettem.

3 Elsődleges leró statisztika

A teljes adatbázis 7 fájlt tartalmaz, ezek közül 6 .csv és 1 .geojson formátum.

Már a Kaggle-n lévő előnézetnél egyértelmű volt, hogy nem lesz szükségem mindegyik táblára, ezért első körben elhagytam a .geojson fájlt és a maradék 6 táblát egyesével is megnéztem.

3.1 A táblákban található változók

Az egszerűbb áttekinthetőség kedvéért kiírattam a különböző táblák változóit és kiválasztottam azokat a változókat amiket a végső adatbázisban fel fogok használni.

Megjegyzés ehhez a szakaszhoz ami a prezentáción szóban fog elhangzani: Első tervben ehhez a szakaszhoz minden tábláról szerettem volna summary()-t kiíratni, de ez a változók sokasága miatt nem volt se áttekinthető se esztétikus. Természetesen megnéztem a táblákat, de itt csak a neveket listázom és a későbbiekben kerülnek elő summary-k. Kihagyhattam volna a táblák eredeti bemutatását, de jobbnak láttam teljesen az elejétől bemutatni milyen lépéseket tettem

3.1.1 Calendar

listing_id date available price adjusted_price minimum_nights maximum_nights
336834 2019-09-19 f $63.00 $63.00 5 250
6369 2019-09-19 f $70.00 $70.00 1 365
6369 2019-09-20 f $75.00 $75.00 1 365

3.1.2 Listings

id name host_id host_name neighbourhood_group neighbourhood latitude longitude room_type price minimum_nights number_of_reviews last_review reviews_per_month calculated_host_listings_count availability_365
6369 Rooftop terrace room with ensuite bathroom, Airc. 13660 Simon Chamartín Hispanoamérica 40.45628 -3.67763 Private room 70 1 65 2019-09-04 0.56 1 53
21853 Bright and airy room 83531 Abdel Latina Cármenes 40.40341 -3.74084 Private room 17 4 33 2018-07-15 0.55 2 48
24805 Gran Via Studio Madrid 101471 Iraido Centro Universidad 40.42202 -3.70395 Entire home/apt 80 5 2 2017-07-03 0.03 1 354

3.1.3 Listings detailed

(A táblában 106 változó van)

id listing_url scrape_id last_scraped name summary space description experiences_offered neighborhood_overview notes transit access interaction house_rules thumbnail_url medium_url picture_url xl_picture_url host_id host_url host_name host_since host_location host_about host_response_time host_response_rate host_acceptance_rate host_is_superhost host_thumbnail_url host_picture_url host_neighbourhood host_listings_count host_total_listings_count host_verifications host_has_profile_pic host_identity_verified street neighbourhood neighbourhood_cleansed neighbourhood_group_cleansed city state zipcode market smart_location country_code country latitude longitude is_location_exact property_type room_type accommodates bathrooms bedrooms beds bed_type amenities square_feet price weekly_price monthly_price security_deposit cleaning_fee guests_included extra_people minimum_nights maximum_nights minimum_minimum_nights maximum_minimum_nights minimum_maximum_nights maximum_maximum_nights minimum_nights_avg_ntm maximum_nights_avg_ntm calendar_updated has_availability availability_30 availability_60 availability_90 availability_365 calendar_last_scraped number_of_reviews number_of_reviews_ltm first_review last_review review_scores_rating review_scores_accuracy review_scores_cleanliness review_scores_checkin review_scores_communication review_scores_location review_scores_value requires_license license jurisdiction_names instant_bookable is_business_travel_ready cancellation_policy require_guest_profile_picture require_guest_phone_verification calculated_host_listings_count calculated_host_listings_count_entire_homes calculated_host_listings_count_private_rooms calculated_host_listings_count_shared_rooms reviews_per_month
6369 https://www.airbnb.com/rooms/6369 20190919050215 2019-09-19 Rooftop terrace room with ensuite bathroom, Airc. Atico en la calle Principe de Vergara, con baño ensuite y acceso directo a gran terraza. Literalmente al lado del metro Colombia , directo al aeropuerto y al recinto ferial IFEMA Feria de Madrid. Close to Real Madrid stadium. BETTER THAN A HOTEL.Upscale neighboorhood (Metro Colombia direct to airport,super convenient entrance right next to the building ). Lots of shops. 20min by public transport to downtown (direct bus or subway). The non smoking room ,(16sqm/ 180sqfeet) with double bed , has lots of privacy with its own ENSUITE BATHROOM-inside the room- and a door with direct access to the huge sunny and full of plants terraCEe(620 sq feet / 60 sqm)). The room has as well AIR CON / HEATING and WIFI INTERNET. Guests have full acces to the rest of the flat, including kitchen with all appliances (coffe machine, microwave, water boiler, dishwasher : no need to clean dishes!, etc… The apartment is situated in a pleasant neighborhood. Contact , please, if you need more information about the apartment, amenities or the situation where it is in Madrid , i will be happy to reply your questions. Thank you and BETTER THAN A HOTEL.Upscale neighboorhood (Metro Colombia direct to airport,super convenient entrance right next to the building ). Lots of shops. 20min by public transport to downtown (direct bus or subway). The non smoking room ,(16sqm/ 180sqfeet) with double bed , has lots of privacy with its own ENSUITE BATHROOM-inside the room- and a door with direct access to the huge sunny and full of plants terraCEe(620 sq feet / 60 sqm)). The room has as well AIR CON / HEATING and WIFI INTERNET. Guests have full acces to the rest of the flat, including kitchen with all appliances (coffe machine, microwave, water boiler, dishwasher : no need to clean dishes!, etc… The apartment is situated in a pleasant neighborhood. Contact , please, if you need more information about the apartment, amenities or the situation where it is in Madrid , i will be happy to reply your questions. Thank you and English, spanish, german, russian, some french spoken. We are available for assistance and to make your none Nice and definitely non touristic neighborhood with plenty of shops and restaurants. A market is across the Street as well as a couple of supermarkets and take away food shops. Some nice bars to hang around during the day and in the evening full of locals. If you are a group/family 3 or 4 people we offer a second extra bedroom for reasonable price. Excelent public transport and easy Access to metro and airport and IFEMA exhibition center. Metro opens at 6am and is 4 or 6 stops from the airport, depending on the terminal. The metro has lift in case you have bulky lugagge. Taxi to airport is flat rate 30 euros ( or around 20 for Cabify). In the area are available electric cars on the go (check car2go, Zity, Emov or Wible). Full use of living room, kitchen (with dishwasher) and terrace . Washing maschine. English, spanish, german, russian, some french spoken. We are available for assistance and to make your stay in Madrid more enjoyable. Felxible check out time. If the room is booked you can leave the lugagge at home and use the common áreas and courtesy bathroom/shower. NA NA https://a0.muscache.com/im/pictures/683224/4cc318c4_original.jpg?aki_policy=large NA 13660 https://www.airbnb.com/users/show/13660 Simon 2009-04-16 Madrid, Madrid, Spain Gay couple, heterofriendly, enjoy having guests home. I am Marketing professional and Simon is contemporary dancer.
Fluent i n several languages: spanish, english , german, russian .. within a few hours 100% N/A f https://a0.muscache.com/im/users/13660/profile_pic/1259103032/original.jpg?aki_policy=profile_small https://a0.muscache.com/im/users/13660/profile_pic/125910303 2/original.jpg?aki_policy=profile_x_medium Hispanoamérica 2 2 [‘email’, ‘phone’, ‘reviews’, ‘jumio’, ‘offline_government_id’, ‘government_id’] t f Madrid, Comunidad de Madrid, Spain Chamartín Hispanoamérica Chamartín Madrid Comunidad de Madrid 28016 Madrid Madrid, Spain ES Spain 40.45628 -3.67763 t Apartment Private room 2 1 1 0 Real Bed {Wifi,“”Air conditioning“”,Kitchen,Elevator,Heating,“”Family/kid friendly“”,Washer,Essentials,Shampoo,Hangers,“”Hair dryer“”,Iron,“”Hot water“”,“”Bed linens“”,“”Extra pillows and blankets“”,“”Pocket wifi“”} 172 $70.00 $350.00 $950.00 $0.00 $5.00 2 $15.00 1 365 1 1 365 365 1 365 2 days ago t 14 23 53 53 2019-09-19 65 6 2010-03-14 2019-09-04 98 10 10 9 10 9 10 t NA f f flexible f f 1 0 1 0 0.56
21853 https://www.airbnb.com/rooms/21853 20190919050215 2019-09-19 Bright and airy room We have a quiet and sunny room with a good view in our 3 bedroom flat. In a welcoming atmosphere, our clean and respectful flatshare is located in a leafy neighbourhood with all facilities: shops, library, cafés and bars, a swimming pools, gyms, and fantastic parks. Well connected by metro and bus with the centre: 15 minutes. For walks, we are also a 20 min stroll away from the riverside. I am living in a nice flat near the centre of Madrid (15 minutes by bus). We are relaxed, clean, and independent. The flat is located in a leafy neighbourhood with plenty of facilities: little shops, supermarkets, public library, swimming pools (covered and summer ones), tennis courts and free parking outside the flat. It is well connected by public transport (various bus and metro lines). The room is sunny and well presented. There are two bathrooms, one of which you would share with a guest. It has triple glazing and we provide fresh bedlinen and towels, so that packing is lighter for our guests. We like clean, relaxed and polite people of any race, country or culture. The building has had a patio with some plants and there is a concierge. We are on the third floor (and yes, there is a lift). There is air conditioning in the living room for the hot summer months, and central heating throughout the entire flat, as well as telephone, fibre optic Internet connection. Long stays are we We have a quiet and sunny room with a good view in our 3 bedroom flat. In a welcoming atmosphere, our clean and respectful flatshare is located in a leafy neighbourhood with all facilities: shops, library, cafés and bars, a swimming pools, gyms, and fantastic parks. Well connected by metro and bus with the centre: 15 minutes. For walks, we are also a 20 min stroll away from the riverside. I am living in a nice flat near the centre of Madrid (15 minutes by bus). We are relaxed, clean, and independent. The flat is located in a leafy neighbourhood with plenty of facilities: little shops, supermarkets, public library, swimming pools (covered and summer ones), tennis courts and free parking outside the flat. It is well connected by public transport (various bus and metro lines). The room is sunny and well presented. There are two bathrooms, one of which you would share with a guest. It has triple glazing and we provide fresh bedlinen and towels, so that packing is lighter for our guests. We none We live in a leafy neighbourhood with plenty of green areas and recreational opportunities such as the library, gyms, swimming pools (covered and summer ones), and the tennis courts. Parking is free outside and it is relatively easy to park near the flat. We are a 15 min bus ride away from the Casa de Campo forest, as well as the zoo and the theme park there. We are also a 20 min stroll to the riverside, and just 5 minutes away from a fantastic park: great for runs and walks. On the other hand, it is not a comfortable accommodation for pets. The flat is near the centre of Madrid (15 minutes by bus). We are well connect by public transport: several buses (31 and 138 and more), metro line L6 and Cercanías trains. If you are bringing your car, parking is free outside. There is a bycicle lane too. There is fibre optic internet connection for you to use. We share the living room and the bathroom is normally shared with one other person only, as there are actually two bathrooms in the flat. Please make sure you you take care to keep it nice and clean, just as we do. Guests can use the kitchen when staying for more than 3 nights. If I am at home and see each other around here, it will be a pleasure to have interesting talks. If you need to ask or let me know about anything, feel free to knock on my bedroom door. Many thanks for not smoking at home. NA NA https://a0.muscache.com/im/pictures/68483181/87bcac58_original.jpg?aki_policy=large NA 83531 https://www.airbnb.com/users/show/83531 Abdel 2010-02-21 Madrid, Madrid, Spain EN-ES-FR
EN
Hi every body: I’m Abdel. I’m spanish original y from Casablanca (Morocco). I’v e been living for many years in Andlusian area and n ow in Madrid that I like very much, since 11 years. My job is related with languages and communication. I’m a quiet person. I don’t smoke, and I do some sport. I like nature, painting and photography.
Please, do ask me any thing you consider usef ul for you.
Kind reg ards.

ES Hola chicos y chicas: soy Abdel. Soy español original de Casablanca, Marruecos. He vivido muchos años en Andalucía y ahora llevo casi 11 años en Madrid, que me encanta. Mi trabajo está relacionado con las lenguas y la comunicación. Soy una persona tranquila y algo reflexiva. No fumo, hago algo de deportes, y me gusta además de la naturaleza, la puntura y la fotografía. En caso de necesidad, no duden en plantearme cualquier pregunta que consideran oportuna. Un cordial saludo.

FR Bonjour, tout le monde, Je suis Abdel, espagnol d’origine marocaine (de Casablanca). J’ai vécu pendant plusieurs années en Andalousie, mais maintenant je suis installé à Madrid depuis 11 ans. Je suis une personne cool et un peu pensatif. Je ne fume pas et je pratique un peu de sport. D’autre part, je suis un amoureux de la nature, la peinture et la photographie. S’il vous plait, n’hesitez pas de me poser des questions, si vous en avez besoin … Cordialement, N/A N/A N/A f https://a0.muscache.com/im/users/83531/profile_pic/1338760896/original.jpg?aki_policy=profile_small https://a0.muscache.com/im/users/83531/profile_pic/1338760896/original.jpg?aki_policy=profile_x_medium Aluche 2 2 [‘email’, ‘phone’, ‘reviews’, ‘manual_offline’, ‘jumio’, ‘offline_government_id’, ‘government_id’] t t Madrid, Madrid, Spain Aluche Cármenes Latina Madrid Madrid 28047 Madrid Madrid, Spain ES Spain 40.40341 -3.74084 f Apartment Private room 1 1 1 1 Real Bed {TV,Internet,Wifi,“”Air conditioning“”,Kitchen,“”Free parking on premises“”,Doorman,Elevator,Heating,Washer,“”First aid kit“”,“”Fire extinguisher“”,Essentials,Shampoo,“”Lock on bedroom door“”,Hangers,“”Hair dryer“”,Iron,“”Laptop friendly workspace“”,“”translation missing: en.hosting_amenity_49“”,“”translation missing: en.hosting_amenity_50“”,“”Hot water“”,“”Bed linens“”,“”Extra pillows and blankets“”,“”Pocket wifi“”,Microwave,“”Coffee maker“”,Refrigerator,“”Dishes and silverware“”,“”Cooking basics“”,Oven} 97 $17.00 $98.00 $370.00 1 $8.00 4 40 4 4 40 40 4 40 8 months ago t 0 0 0 48 2019-09-19 33 0 2014-10-10 2018-07-15 92 9 9 10 10 8 9 t NA f f strict_14_with_grace_period f f 2 0 2 0 0.55 24805 https://www.airbnb.com/rooms/24805 20190919050215 2019-09-19 Gran Via Studio Madrid Studio located 50 meters from Gran Via, next to the Plaza de Callao. In the best shopping and cinemas and theaters. Comfortable apartment for 3 people. 1 bed and the sofa bed in the lounge. Fully furnished. LOCATION. Brand new flats near the Atlantic Hotel, 50 meters from Gran Vía and Zara, H & M, Desigual, theaters and all the premieres and Music of Madrid. This home is located in a prime location in the heart of entertainment and shopping. A step away from everything you want to see in Madrid. The Puerta del Sol, Plaza Mayor, the Mercado de San Miguel, Theatre Royal and Royal Palace The area is known as Plaza de Callao and near Chueca, Plaza Mayor is the most emblematic monument of the city, where cultural and leisure activities is concentrated: international restaurants, terraces and shops trends. No need or public transportation, you’re just steps from the famous La Latina, the Royal Palace, Opera House, Sun, and of course Gran Via Best gourmet tapas at Mercado de San Miguel, amazing renovated modernist building, right on the corner. 1 minute from the Puerta del Sol, the street price and Calle Fuencarral, Chueca and all the more modern part of Madrid A 1 minute (50 m) of Gran Via Studio located 50 meters from Gran Via, next to the Plaza de Callao. In the best shopping and cinemas and theaters. Comfortable apartment for 3 people. 1 bed and the sofa bed in the lounge. Fully furnished. LOCATION. Brand new flats near the Atlantic Hotel, 50 meters from Gran Vía and Zara, H & M, Desigual, theaters and all the premieres and Music of Madrid. This home is located in a prime location in the heart of entertainment and shopping. A step away from everything you want to see in Madrid. The Puerta del Sol, Plaza Mayor, the Mercado de San Miguel, Theatre Royal and Royal Palace The area is known as Plaza de Callao and near Chueca, Plaza Mayor is the most emblematic monument of the city, where cultural and leisure activities is concentrated: international restaurants, terraces and shops trends. No need or public transportation, you’re just steps from the famous La Latina, the Royal Palace, Opera House, Sun, and of course Gran Via Best gourmet tapas at Mercado de San Miguel, a none The area is next to the Gran Via, so people living in the area is mostly tourists. Being so well located, it is very interesting for short stays. Just enjoy your trip. To go from the airport you have several different options: - By Metro (You take the “”line 8“” metro to Nuevos Ministerios, there you take the “”line 10“” Puerta del Sur direction and get off at Alonso Martinez and change “line 5” from Callao Station, takes about 35 minutes and costs 4,5€). - By taxi (approximately 20 minutes and costs about 30 €). - By bus (there is an express bus, takes about 35 minutes to Cibeles, then you have to take the subway in Banco de España “”line 2“” Cuatro Caminos direction, until Sol, take the “”Line 1“” in direction Pinar de Chamartin and down in Callao, in total takes about 50 minutes). I recommend the subway, it is cheaper and you have no problem with the suitcase (Madrid is very safe, but beware of pickpockets on the subway and in tourist areas). I think it does go by metro take you 1 hour between taking the suitcase, through customs and the metro. Anyway if you see that the flight is delayed let me know before leaving to better estimate arrival time. The apa Apartment with elevator has a storage room for guests to deposit their bags. Very well connected and located 50 meters from all shops. I put at the disposal of my guests to facilitate information Madrid. During your stay it is your home. Feel it as if it were. I will make you feel special. Please do not smoke. Pets not allowed the rules for use of the apartment is all that we apply in our own home. Respect to neighbors, and cleanliness of the apartment and common areas. From 22 hrs. A supplement of 20 € will be charged for late arrive to be paid at the time of arrival. NA NA https://a0.muscache.com/im/pictures/5843578f-6a14-403c-b327-5c62a0d1be7d.jpg?aki_policy=large NA 101471 https://www.airbnb.com/users/show/101471 Iraido 2010-03-31 Madrid, Madrid, Spain I love treating my clients, how I would like them to treat me.

I like new technologies, football (not fan man), movies and most important my family. I want you to feel special in my apartment, to call me if you have any problem. I want your stay in Madrid to be special. I wait for you.

**Me encanta tratar a mis clientes, como me gustaria que me trataran a mi.

Me gustan las nuevas tecnologías, el fútbol (sin pasarme), el cine y lo mas importante en mi vida es mi familia. Quiero que te sientas especial en mi apartamento, que me llames si tienes cualquier problema, tanto en el piso como de cualquier tema. Quiero que tu estancia en Madrid sea especial. Te espero. within a day 100% N/A f https://a0.muscache.com/im/pictures/user/233f48ef-47ac-463d-afdc-eede22cf636b.jpg?aki_policy=profile_small https://a0.muscache.com/im/pictures/user/233f48ef-47ac-463d-afdc-eede22cf636b.jpg?aki_policy=profile_x_medium Malasaña 1 1 [‘email’, ‘phone’, ‘facebook’, ‘reviews’, ‘jumio’, ‘government_id’, ‘work_email’] t t Madrid, Madrid, Spain Malasaña Universidad Centro Madrid Madrid 28004 Madrid Madrid, Spain ES Spain 40.42202 -3.70395 t Apartment Entire home/apt 3 1 0 1 Real Bed {TV,Internet,Wifi,“”Air conditioning“”,Kitchen,Elevator,“”Buzzer/wireless intercom“”,Heating,“”Family/kid friendly“”,Washer,“”Fire extinguisher“”,Essentials,Shampoo,“”24-hour check-in“”,Hangers,“”Hair dryer“”,Iron,“”Laptop friendly workspace“”,“”Pack ’n Play/travel crib“”,“”Hot water“”,Microwave,“”Coffee maker“”,Refrigerator,“”Dishes and silverware“”,“”Cooking basics“”,Oven,Stove,“”Luggage dropoff allowed“”,“”Long term stays allowed“”,“”Cleaning before checkout“”,“”Host greets you“”,“”Paid parking on premises“”} 0 $80.00 $450.00 $1,200.00 $200.00 $30.00 2 $0.00 5 730 5 5 730 730 5 730 1 week ago t 19 49 79 354 2019-09-19 2 0 2014-11-29 2017-07-03 100 8 8 10 10 10 10 t NA f f moderate f f 1 1 0 0 0.03

3.1.4 Neighbourhoods

neighbourhood_group neighbourhood
Arganzuela Acacias
Arganzuela Atocha
Arganzuela Chopera

3.1.5 Reviews

listing_id date
6369 2010-03-14
6369 2010-03-23
6369 2010-04-10

3.1.6 Reviews detailed

listing_id id date reviewer_id reviewer_name comments
6369 29428 2010-03-14 84790 Nancy Simon and Arturo have the ultimate location in Madrid! Steps from the Metro and bus line to everywhere you want to visit. The accomodations are clean, well appointed and fantastic views of Madrid skyline. We felt like it was a spa when walking into the flat. We were greeted warmly and offered lots of information to get up and running for our short stay. We wished we could have stayed longer and we highly recommend this location and neighborhood.
6369 31018 2010-03-23 84338 David Myself and Kristy originally planned on staying with Arturo for only a week, but when our plans changed, Arturo was very open to working with our changing schedule. Arturo and Simon were very friendly and helpful throughout our ten day visit. Our room was very clean and well kept. The view is amazing and the location is perfect. We’re going to be traveling around Europe for another four months, and were joking that Arturo set the standards so high that we highly doubt we’re going to be able to do any better, and it’s true! Thank you so much Arturo and Simon, you were both very gracious, helpful and respectful of our space. I would highly recommend you and your flat to anyone traveling who wants a quite place with a great views, wonderful/clean rooms, a respectful and honest atmosphere. Thank you so much for being such an outstanding host!
6369 34694 2010-04-10 98655 Marion We had a great time at Arturo and Simon’s ! A cosy apartment and a wonderful terrasse, and above all, really nice hosts ! Thank you…

3.2 A végleges tábla elkészítése

Ha végiglapozzuk a táblákat akkor láthatjuk, hogy a Neighbourhoods és Reviews tábla elhagyható, mivel ezek az értékekjelen vannak másik táblákban. A legtöbb változót kétség kívül a listings_detailed táblából kell elhagyni, illetve nincs értelme megtartani a szöveges értékeléseket. Azokat az oszlopokat ahol szöveges kategóriák vannak (amik könnyen átalakíthatók) megtartottam, hátha valami érdekes is látszik belőle.

A táblákat az apartmanok id-ja alapján tudjuk összekapcsolni és a következő változókat hagytam meg:

listing_id (szállás id-ja), date, avaiable, price, minimum nights, maximum nights host id, neighbourhood, neighbourhood group, room type, number of reviews, last review, availability host response time, host response rate, host is superhost, host neighbourhood, host listings count, host has profile pic, host identity verified, neighbourhood, is location exact, property type, room type, accomodates, bathrooms, bedrooms, beds, bedtype, squarefeet, weekly price, montly price, security deposit, cleaning fee, extra people, calendar updated, has availability, review scores (mindegyik típus), requires licence, cancellation policy, require guest profile picture

Ami változók érdekesek lettek volna de szövegből nem tudtam “visszafejteni”: amenities

4 Az “idő” problémája

Sajnos a valós foglaltsági adatok nem elérhetők. Ezt az adatot az ár várható értéke esetén is érdemes lenne tudn, legalábbis az occupancy rate-t. Szerencsé(m)re az Inside Airbnb csapat közzé tette a módeszert amivel ők egy tanulmány alapján kiszámolták a foglaltságot.

A válasz az értékelésekben rejlik, illetve a számukban, és a módszer a következő lépésekből áll: 1. 50%-os értékelési ráta -> minden második vendég hagy értékelést 2. Az értékelések számát megszorozzuk a városra jellemző átlagos tartózkodással (ez madrid esetében 4,6 nap) https://www.airbnbcitizen.com/wp-content/uploads/2015/06/Madrid-release-ENG.pdf 3. Beállítunk egy 70%-os maximum kihasználtságot

Ez az adatbázis egy szept. 19-i gyűjtés. A korábbi illetve későbbi gyűjtések közzött a változó adatok a reviews és calendar táblákban találhatók. Mivel a kihasználtságot a reviews alapján becslik a fenti módszerrel, a szept. 19-i értékeléseket frissítettem az októberi értékelésekkel. Az új értékelésket október 14-ig emeltem be, így a szeptemberi vendégéjszakákat tudtam becsülni. (Az Airbnb szerint egy vendég maximum 2 héten belül hagy értékelést.)

Az Airbnb jellegéből adódoan - nem több szobás, elvileg nem tisztán “hostel” - ne felejtsük el, hogy egy-egy Airbnb em közönségcélpont, így nem feltétlenül az a cél hogy pont abban az apartmanban szálljunk meg. Ezért nem vetettem össze a korábbi calendarokat.

5 Végeleges adatbázis a megadott változókkal

A megfigyeléseket leszűkítettem 2019. június 1. és 2019. szeptember 30. között.

#Első körben a két "óriás" adatfájlt, calendart és a reviews-t szűkítettem le időben.
summary(reviewsoctober$date)
##    Length     Class      Mode 
##    751580 character character
reviews <- subset(reviewsoctober, reviewsoctober$date >= "2019-06-06" & reviewsoctober$date<="2019-10-14")

summary(reviews$date)
##    Length     Class      Mode 
##    119576 character character

A calendar file-t ezen a ponton elhagytam, mivel egy szept. 19-én látható elérhetőségen kívül más extra információt nem tartalmazott a többi változóhoz képest.

#Merge előtt leszűkítem a táblákat


listings_total1 <- listings[ , c("id", "host_id", "neighbourhood_group", "room_type", "price", "number_of_reviews", "reviews_per_month", "availability_365")]
listings_total2 <- listings_detailed[ , c("id", "host_response_time", "host_response_rate", "host_is_superhost", "host_listings_count", "host_has_profile_pic", "host_identity_verified", "is_location_exact", "property_type", "accommodates", "bathrooms", "bedrooms", "beds", "bed_type", "weekly_price", "monthly_price", "security_deposit", "cleaning_fee", "maximum_nights", "has_availability", "last_review", "review_scores_rating", "review_scores_checkin", "review_scores_accuracy", "review_scores_cleanliness", "review_scores_communication", "review_scores_location", "review_scores_value", "instant_bookable", "cancellation_policy", "require_guest_profile_picture", "availability_30")]

listings_total <- merge(listings_total1, listings_total2, by="id")

listings_total$id <- as.character(listings_total$id)

nrow(listings_total)
## [1] 20837
#A szállások száma
##         listing_id       date
##      1:       6369 2019-09-04
##      2:       6369 2019-09-28
##      3:       6369 2019-10-05
##      4:       6369 2019-10-10
##      5:      24805 2019-10-02
##     ---                      
## 119572:   39286624 2019-10-12
## 119573:   39286624 2019-10-12
## 119574:   39286624 2019-10-13
## 119575:   39335649 2019-10-14
## 119576:   39350078 2019-10-14
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##     6369 16089849 24594736 23560257 34013184 38730025
##        id               date              host_id          neighbourhood_group
##  Min.   :    6369   Length:118154      Min.   :     5154   Length:118154      
##  1st Qu.:15144308   Class :character   1st Qu.: 21807514   Class :character   
##  Median :22537740   Mode  :character   Median : 69805790   Mode  :character   
##  Mean   :21919855                      Mean   : 96136964                      
##  3rd Qu.:30805887                      3rd Qu.:158946129                      
##  Max.   :38730025                      Max.   :295894160                      
##                                                                               
##   room_type             price         number_of_reviews reviews_per_month
##  Length:118154      Min.   :   9.00   Min.   :  0.00    Min.   : 0.020   
##  Class :character   1st Qu.:  44.00   1st Qu.: 25.00    1st Qu.: 2.310   
##  Mode  :character   Median :  64.00   Median : 66.00    Median : 3.780   
##                     Mean   :  77.65   Mean   : 95.54    Mean   : 4.134   
##                     3rd Qu.:  90.00   3rd Qu.:137.00    3rd Qu.: 5.480   
##                     Max.   :9999.00   Max.   :594.00    Max.   :34.230   
##                                                         NA's   :1159     
##  availability_365 host_response_time host_response_rate host_is_superhost 
##  Min.   :  0      Length:118154      Length:118154      Length:118154     
##  1st Qu.: 65      Class :character   Class :character   Class :character  
##  Median :140      Mode  :character   Mode  :character   Mode  :character  
##  Mean   :167                                                              
##  3rd Qu.:293                                                              
##  Max.   :365                                                              
##                                                                           
##  host_listings_count host_has_profile_pic host_identity_verified
##  Min.   :  0.00      Length:118154        Length:118154         
##  1st Qu.:  1.00      Class :character     Class :character      
##  Median :  3.00      Mode  :character     Mode  :character      
##  Mean   : 11.73                                                 
##  3rd Qu.:  7.00                                                 
##  Max.   :525.00                                                 
##  NA's   :150                                                    
##  is_location_exact  property_type       accommodates      bathrooms     
##  Length:118154      Length:118154      Min.   : 1.000   Min.   : 0.000  
##  Class :character   Class :character   1st Qu.: 2.000   1st Qu.: 1.000  
##  Mode  :character   Mode  :character   Median : 4.000   Median : 1.000  
##                                        Mean   : 3.674   Mean   : 1.263  
##                                        3rd Qu.: 4.000   3rd Qu.: 1.500  
##                                        Max.   :16.000   Max.   :16.500  
##                                                         NA's   :10      
##     bedrooms           beds          bed_type         weekly_price      
##  Min.   : 0.000   Min.   : 0.000   Length:118154      Length:118154     
##  1st Qu.: 1.000   1st Qu.: 1.000   Class :character   Class :character  
##  Median : 1.000   Median : 2.000   Mode  :character   Mode  :character  
##  Mean   : 1.389   Mean   : 2.122                                        
##  3rd Qu.: 2.000   3rd Qu.: 3.000                                        
##  Max.   :50.000   Max.   :59.000                                        
##  NA's   :24       NA's   :16                                            
##  monthly_price      security_deposit   cleaning_fee       maximum_nights    
##  Length:118154      Length:118154      Length:118154      Min.   :     1.0  
##  Class :character   Class :character   Class :character   1st Qu.:    40.0  
##  Mode  :character   Mode  :character   Mode  :character   Median :  1125.0  
##                                                           Mean   :   734.7  
##                                                           3rd Qu.:  1125.0  
##                                                           Max.   :100000.0  
##                                                                             
##  has_availability   last_review        review_scores_rating
##  Length:118154      Length:118154      Min.   : 20.00      
##  Class :character   Class :character   1st Qu.: 91.00      
##  Mode  :character   Mode  :character   Median : 95.00      
##                                        Mean   : 93.49      
##                                        3rd Qu.: 97.00      
##                                        Max.   :100.00      
##                                        NA's   :1282        
##  review_scores_checkin review_scores_accuracy review_scores_cleanliness
##  Min.   : 2.000        Min.   : 2.000         Min.   : 2.000           
##  1st Qu.:10.000        1st Qu.: 9.000         1st Qu.: 9.000           
##  Median :10.000        Median :10.000         Median :10.000           
##  Mean   : 9.731        Mean   : 9.656         Mean   : 9.512           
##  3rd Qu.:10.000        3rd Qu.:10.000         3rd Qu.:10.000           
##  Max.   :10.000        Max.   :10.000         Max.   :10.000           
##  NA's   :1283          NA's   :1282           NA's   :1282             
##  review_scores_communication review_scores_location review_scores_value
##  Min.   : 2.000              Min.   : 2.000         Min.   : 2.000     
##  1st Qu.:10.000              1st Qu.:10.000         1st Qu.: 9.000     
##  Median :10.000              Median :10.000         Median : 9.000     
##  Mean   : 9.762              Mean   : 9.783         Mean   : 9.329     
##  3rd Qu.:10.000              3rd Qu.:10.000         3rd Qu.:10.000     
##  Max.   :10.000              Max.   :10.000         Max.   :10.000     
##  NA's   :1282                NA's   :1283           NA's   :1283       
##  instant_bookable   cancellation_policy require_guest_profile_picture
##  Length:118154      Length:118154       Length:118154                
##  Class :character   Class :character    Class :character             
##  Mode  :character   Mode  :character    Mode  :character             
##                                                                      
##                                                                      
##                                                                      
##                                                                      
##  availability_30
##  Min.   : 0.00  
##  1st Qu.: 2.00  
##  Median : 5.00  
##  Mean   : 6.23  
##  3rd Qu.: 9.00  
##  Max.   :30.00  
## 

6 Június-Szeptember becsült foglalási arány kiszámítása

#Első lépés az értékelések száma apartmanonként
#Bökkenő: nem egyértelműen eldönthetőhogy egy hó eleji értékelés arra a hónapra vagy a korábbira vonatkozott. Hogy mindegyik hónapot külön tudjam vizsgálni újabb egyszerűsítéssel éltem. Az előző havi értékeléseknek "1 hét haladékot" számoltam, szeptember esetében pedig 2-t.

total <- total[, month:= ifelse(date>="2019-09-07", "September",
                                ifelse(date>="2019-08-07", "August", 
                                       ifelse(date>="2019-07-07", "July", "June")))]

#Ez alapj összesíthetjük egy szállást az adott hónapban hányszor foglaltak ki. Az Airbnb legfrisebb becslése 2015-ös amiben az átlagos tartózkodást 4,6 napra becsülték. Az Inside Airbnb csapata ismeretlen friss adat esetén 3 napos tartózkodással becsül. Mielőtt meghatároztam volna azt a számot amivel én becslem a napok számát, kíváncsi voltam a foglalási arányok eloszlására.
min(total$date)
## [1] "2019-06-06"
#Kíváncsi voltam csúszott-e hiba a táblázatba ezért kikértem azokat a szállásokat ahol az utolsó értékelés június 1. előtt volt. Meglepő módon kilistázott közel 2000 sort, de mindegyiknél volt friss értékelés.
hiba <- subset(total, total$last_review<="2019-06-01")
range(total$last_review)
## [1] ""           "2019-09-19"
range(total$date)
## [1] "2019-06-06" "2019-10-14"
#Number of bookings per month

total <- total[, total_bookings:= (count=.N), by=id]
#50%-os szabálynál
total <- total[, total_bookings:= (total_bookings*2), by=id]

total <- total[, monthly_bookings:=(count=.N), by=.(id, month)]
total <- total[, monthly_bookings:=(monthly_bookings*2), by=.(id, month)]

bookings <- total[, total_bookings, by=id]
bookings <- unique(bookings)

hist <- ggplot(bookings, aes(total_bookings))+geom_histogram(bins=100)+theme_classic()+ggtitle("Becsült foglalások számának eloszlása a teljes időszakban") + xlab("Foglalások száma/szálláshely") + ylab("Gyakoriság")
hist

summary(bookings$total_bookings)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    2.00    6.00   14.00   19.53   28.00  316.00

4 hónap alatt kicsit sok 316 foglalás - és fizikailag lehetetlen. Nézzük meg a havi foglalásokat

bookings_monthly <- total[, c("id","monthly_bookings", "month")]
bookings_monthly <- unique(bookings_monthly)

hist_2 <-ggplot(bookings_monthly, aes(monthly_bookings, fill=month))+geom_histogram(bins=100)+theme_classic()+ggtitle("Becsült foglalások számának eloszlása havi felbontásban") + xlab("Foglalások száma/szálláshely") + ylab("Gyakoriság")+facet_grid(rows=vars(month))
hist_2

august <- bookings_monthly[ month=="August"]
summary(august)
##        id           monthly_bookings     month          
##  Min.   :    6369   Min.   :  2.000   Length:6800       
##  1st Qu.:15562674   1st Qu.:  2.000   Class :character  
##  Median :23350278   Median :  6.000   Mode  :character  
##  Mean   :22498718   Mean   :  6.565                     
##  3rd Qu.:31480291   3rd Qu.:  8.000                     
##  Max.   :38236520   Max.   :120.000

Következő lépés az outlierek “eltüntetése”.

  1. lépés: az 50%-os rátát közelítettem az Airbnb 72%-hoz, így tegyük fel, hogy 3-ból 2 ember hagy értékelést. A szorzó így 2-ről 1,5-re módosulna. Sajnos az R nem tudta kezelni a törteket (illetve én nem tudtam beállítani, hogy hatékonyan kezelje) így maradtam a 2-es szorzónál.

Mivel eddig foglalásokról volt szó (1 értékelés=2 foglalás), a napokkal egyéltalán nem is foglalkoztunk.

Ezen a ponton kissé kezdett bonyolódni a feladat és a becslés egyre jobban torzult, ezért nem a napokra fókuszáltam, hanem a havi foglalások számára.

Meg kellett becsülni egy keretet ami közelíthet a valósághoz. Első körben visszaállítottam az értékelési rátát 100%-ra, majd beállítottam egy havi maximum 12 foglalásos limitet. Ez átlag 2 éjszakás tartózkodás mellett is több mint havi 70%-os kihasználtságot jelent egy-egy szállás esetén.

total <- total[, total_bookings:= (count=.N), by=id]
total <- total[, monthly_bookings:=(count=.N), by=.(id, month)]

outlier <- subset(total, total$monthly_bookings> 12)
nrow(outlier)
## [1] 4687
#Kevesebb mint 5000 sor esik ki

total <- subset(total, total$monthly_bookings< 13)
total <- total[, total_bookings:= (count=.N), by=id]


max(total$total_bookings)
## [1] 44
max(total$monthly_bookings)
## [1] 12

Ismét a hisztogramok:

bookings2 <- total [, c("id","total_bookings")]
bookings2 <- unique(bookings2)

hist <- ggplot(bookings2, aes(total_bookings))+geom_histogram(bins=100)+theme_classic()+ggtitle("Becsült foglalások számának eloszlása a teljes időszakban") + xlab("Foglalások száma/szálláshely") + ylab("Gyakoriság")
hist

max(bookings2$total_bookings)
## [1] 44
bookings_monthly <- total[, c("id","monthly_bookings", "month")]
bookings_monthly <- unique(bookings_monthly)

hist_2 <-ggplot(bookings_monthly, aes(monthly_bookings, fill=month))+geom_histogram(bins=10)+theme_classic()+ggtitle("Becsült foglalások számának eloszlása havi felbontásban") + xlab("Foglalások száma/szálláshely") + ylab("Gyakoriság")+facet_grid(rows=vars(month))
hist_2

7 Összefüggések a többi változóval

Miután elkészült egy könnyen használható adatbázis, a következő összefüggéseket vizsgáltam ##Neighbourhood hatása

hist_3 <-ggplot(total, aes(total_bookings, fill=neighbourhood_group))+geom_histogram(bins=10)+theme_classic()+ggtitle("Becsült foglalások számának eloszlása környékre vonatkozólag") + xlab("Foglalások száma/szálláshely") + ylab("Gyakoriság")

hist_3

Bár nagy a kerületek/szomszédságok száma, látszik, hogy a legkedveltebb a “Centro”.

Átlagolva:

total <- total[, mean_nbh:=(mean(total_bookings)), by=neighbourhood_group]
hist4 <- total[, c("mean_nbh", "neighbourhood_group")]
hist4 <- unique(hist4)
hist_4 <-ggplot(hist4, aes(x=neighbourhood_group, y=mean_nbh, fill=neighbourhood_group))+geom_bar(stat="identity",position="dodge")+ggtitle("Becsült foglalások átlaga környékre vonatkozólag") + xlab("Neighbourhoods") + ylab("Átlagos foglaltság")+labs(fill="Neighbourhoods")

hist_4

A különség a szálláshelyek számában keresendő:

nb_id <- total[, c("id", "neighbourhood_group")]
nb_id <- unique(nb_id)
nb_id <- nb_id[, number:=(count=.N), by=neighbourhood_group]

plot <-ggplot(nb_id, aes(x=neighbourhood_group, y=number, fill=neighbourhood_group))+geom_bar(stat="identity",position="dodge")+ggtitle("Szállások száma neighbourhood alapján") + xlab("Neighbourhoods") + ylab("Szállások száma")+labs(fill="Neighbourhoods")
plot

7.1 Szállások atrribútumai

7.1.1 Szállás típusa

plot <- ggplot(total, aes(x=total_bookings ,fill=bed_type))+geom_bar()+facet_wrap(vars(bed_type), scales = "free")+ggtitle("Foglalások és az ágyak típusa") + xlab("Teljes foglalások száma") + ylab("Foglalások száma")+labs(fill="Ágytípus")
plot

7.1.2 Válaszidő

plot <- ggplot(total, aes(x=total_bookings ,fill=host_response_time))+geom_bar()+facet_wrap(vars(host_response_time), scales = "free")+ggtitle("Összes foglalás és válaszidő") + xlab("Teljes foglalások száma") + ylab("Foglalások száma")+labs(fill="Válaszidó")
plot

7.1.3 Igazoltatás

plot <- ggplot(total, aes(x=total_bookings ,fill=host_identity_verified))+geom_bar()+facet_wrap(vars(host_identity_verified), scales = "free")+ggtitle("") + xlab("Foglalások száma szálláshelyenként") + ylab("Összes foglalások száma")+labs(fill="Host ellenőrzött-e")
plot

plot2 <- ggplot(total, aes(x=total_bookings ,fill=host_has_profile_pic))+geom_bar()+facet_wrap(vars(host_has_profile_pic), scales = "free")+ggtitle("Profilképek hatása") + xlab("Foglalások száma") + ylab("Összes foglalás száma")+labs(fill="Profilkép")
plot2

7.1.4 Árarány

price_id <- total[, c("id", "price", "month", "monthly_bookings", "total_bookings", "neighbourhood_group")]
price_id <- unique(price_id)

plot <- ggplot(price_id, aes(x=price, y=total_bookings, fill=neighbourhood_group))+geom_point()
plot

summary(total$price)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    9.00   45.00   65.00   78.14   90.00 9999.00
#Kiugró értékek eltávolítása

price_id <- subset(price_id, price<1000)

plot <- ggplot(price_id, aes(x=price, y=total_bookings, fill=neighbourhood_group, color=neighbourhood_group))+geom_point()
plot

plot3 <- ggplot(price_id, aes(x=price, y=total_bookings, fill=neighbourhood_group, color=neighbourhood_group))+geom_point()+facet_grid(scales="free", vars(neighbourhood_group))+labs(fill="Neighbourhood")+xlab("Teljes foglalások száma")+ylab("Ár")
plot3

7.1.5 Értékelések

plot <- ggplot(total, aes(x=review_scores_rating, y=total_bookings ,fill=neighbourhood_group, color=neighbourhood_group))+geom_point()+ggtitle("Foglalások és értékelések") + xlab("Teljes foglalások száma") + ylab("Foglalások száma")
plot
## Warning: Removed 1282 rows containing missing values (geom_point).

8 Összefoglalás

A projektben megpróbáltam bemutatni a madridi Airbnb foglalásainak számát és mutattam pár összefüggést. A projekt tovább fejleszthető (pl. átlagok hozzáadása, többszörös csoportosítás) és másfajta, bonyolultabb becslések is végrehajthatók.

Vizsgálhattam volna várható árakat, de a konzultáció alapján inkább egy leíró jellemzés felé indultam el.

9 Projekt javítása: clusterezés k-means módszerrel

9.0.1 Adatok előkészítése

A visszajelzés alapján nem volt igazán értelme korlátoznom az értékelések számára, ezért az adatbázis az összes értékelést tartalmazza -> hirdetés/júni-szept

Új adattábl ami folytonos változókat tartalmaz

total_cluster <- merge(reviews, listings_total, by="id")

names(total_cluster)
##  [1] "id"                            "date"                         
##  [3] "host_id"                       "neighbourhood_group"          
##  [5] "room_type"                     "price"                        
##  [7] "number_of_reviews"             "reviews_per_month"            
##  [9] "availability_365"              "host_response_time"           
## [11] "host_response_rate"            "host_is_superhost"            
## [13] "host_listings_count"           "host_has_profile_pic"         
## [15] "host_identity_verified"        "is_location_exact"            
## [17] "property_type"                 "accommodates"                 
## [19] "bathrooms"                     "bedrooms"                     
## [21] "beds"                          "bed_type"                     
## [23] "weekly_price"                  "monthly_price"                
## [25] "security_deposit"              "cleaning_fee"                 
## [27] "maximum_nights"                "has_availability"             
## [29] "last_review"                   "review_scores_rating"         
## [31] "review_scores_checkin"         "review_scores_accuracy"       
## [33] "review_scores_cleanliness"     "review_scores_communication"  
## [35] "review_scores_location"        "review_scores_value"          
## [37] "instant_bookable"              "cancellation_policy"          
## [39] "require_guest_profile_picture" "availability_30"

Folytonos, numerikus változók:

total_cluster[, sapply(total_cluster, is.numeric)]
##                            id                          date 
##                          TRUE                         FALSE 
##                       host_id           neighbourhood_group 
##                          TRUE                         FALSE 
##                     room_type                         price 
##                         FALSE                          TRUE 
##             number_of_reviews             reviews_per_month 
##                          TRUE                          TRUE 
##              availability_365            host_response_time 
##                          TRUE                         FALSE 
##            host_response_rate             host_is_superhost 
##                         FALSE                         FALSE 
##           host_listings_count          host_has_profile_pic 
##                          TRUE                         FALSE 
##        host_identity_verified             is_location_exact 
##                         FALSE                         FALSE 
##                 property_type                  accommodates 
##                         FALSE                          TRUE 
##                     bathrooms                      bedrooms 
##                          TRUE                          TRUE 
##                          beds                      bed_type 
##                          TRUE                         FALSE 
##                  weekly_price                 monthly_price 
##                         FALSE                         FALSE 
##              security_deposit                  cleaning_fee 
##                         FALSE                         FALSE 
##                maximum_nights              has_availability 
##                          TRUE                         FALSE 
##                   last_review          review_scores_rating 
##                         FALSE                          TRUE 
##         review_scores_checkin        review_scores_accuracy 
##                          TRUE                          TRUE 
##     review_scores_cleanliness   review_scores_communication 
##                          TRUE                          TRUE 
##        review_scores_location           review_scores_value 
##                          TRUE                          TRUE 
##              instant_bookable           cancellation_policy 
##                         FALSE                         FALSE 
## require_guest_profile_picture               availability_30 
##                         FALSE                          TRUE

Ami ebből numerikussá alakítható: weekly_price, monthly_price, security_deposit, cleaning_fee

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:data.table':
## 
##     between, first, last
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
total_cluster <- total_cluster[, weekly_price:=as.numeric(weekly_price)]
## Warning in eval(jsub, SDenv, parent.frame()): NAs introduced by coercion
total_cluster <- total_cluster[, monthly_price:=as.numeric(monthly_price)]
## Warning in eval(jsub, SDenv, parent.frame()): NAs introduced by coercion
total_cluster <- total_cluster[, security_deposit:=as.numeric(security_deposit)]
## Warning in eval(jsub, SDenv, parent.frame()): NAs introduced by coercion
total_cluster <- total_cluster[, cleaning_fee:=as.numeric(cleaning_fee)]
## Warning in eval(jsub, SDenv, parent.frame()): NAs introduced by coercion
#Nem tudta kezelni, valószínűleg a dollárjel miatt+NA-k

total_cluster <- merge(reviews, listings_total, by="id")

total_cluster[, sapply(total_cluster, is.numeric)]
##                            id                          date 
##                          TRUE                         FALSE 
##                       host_id           neighbourhood_group 
##                          TRUE                         FALSE 
##                     room_type                         price 
##                         FALSE                          TRUE 
##             number_of_reviews             reviews_per_month 
##                          TRUE                          TRUE 
##              availability_365            host_response_time 
##                          TRUE                         FALSE 
##            host_response_rate             host_is_superhost 
##                         FALSE                         FALSE 
##           host_listings_count          host_has_profile_pic 
##                          TRUE                         FALSE 
##        host_identity_verified             is_location_exact 
##                         FALSE                         FALSE 
##                 property_type                  accommodates 
##                         FALSE                          TRUE 
##                     bathrooms                      bedrooms 
##                          TRUE                          TRUE 
##                          beds                      bed_type 
##                          TRUE                         FALSE 
##                  weekly_price                 monthly_price 
##                         FALSE                         FALSE 
##              security_deposit                  cleaning_fee 
##                         FALSE                         FALSE 
##                maximum_nights              has_availability 
##                          TRUE                         FALSE 
##                   last_review          review_scores_rating 
##                         FALSE                          TRUE 
##         review_scores_checkin        review_scores_accuracy 
##                          TRUE                          TRUE 
##     review_scores_cleanliness   review_scores_communication 
##                          TRUE                          TRUE 
##        review_scores_location           review_scores_value 
##                          TRUE                          TRUE 
##              instant_bookable           cancellation_policy 
##                         FALSE                         FALSE 
## require_guest_profile_picture               availability_30 
##                         FALSE                          TRUE
total_cluster <- total_cluster%>%select_if(is.numeric)
#host id eltávolítása
total_cluster <- total_cluster[, -2]

18 folytonos numerikus változó + apartmanok id-ja

9.0.2 K-means

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✔ tibble  2.1.3     ✔ stringr 1.4.0
## ✔ tidyr   1.0.0     ✔ forcats 0.4.0
## ✔ purrr   0.3.3
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::between()   masks data.table::between()
## ✖ tidyr::extract()   masks magrittr::extract()
## ✖ dplyr::filter()    masks stats::filter()
## ✖ dplyr::first()     masks data.table::first()
## ✖ dplyr::lag()       masks stats::lag()
## ✖ dplyr::last()      masks data.table::last()
## ✖ purrr::set_names() masks magrittr::set_names()
## ✖ purrr::transpose() masks data.table::transpose()
library(cluster)
library(factoextra)
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
# A factoextra csomag beépített grafikont tartalmaz a k megtalálásához, gyorsabb és kevesebb sor mint plotolni

#ID eltávolítása ideiglenesen

#Az ID folytonos változóként veszi, ezért nem hagyhatom benn a scale-nél. Egyelőre nem szedtem külön az apartmanokat, erre most kerül sor

total_cluster <- unique(total_cluster)
total_cluster <- na.omit(total_cluster)
#innentől csak az egyes apartmanokra vonatkozó adatok vannak az adatbázisban, de az összes értékelésszám benne van

rownames(total_cluster) <- total_cluster$id
total_cluster$id=NULL
cluster_k <- as.data.table(scale(total_cluster))

#MacOs kifut a memóriából, ezért test-set sample (n=5000)

set.seed(122)
cluster_k_sample <- sample(1:nrow(cluster_k), 5000, replace=FALSE)
cluster_k_sample <- cluster_k[cluster_k_sample, ]

cluster_k_sample <- na.omit(cluster_k_sample)

#K elbow módszerrel:

fviz_nbclust(cluster_k_sample, kmeans, method="wss")

#Bend talán k=5-nél?

#másik módszer:Silhouette (maximum keresése)

fviz_nbclust(cluster_k_sample, kmeans, method="silhouette")

#a második ábra alpaján az optimális k=2 (többre számítottam)
#Még egy módszer (Gapstat via: https://uc-r.github.io/kmeans_clustering#fn:scale)

#gap_stat <- clusGap(cluster_k_sample, FUN=kmeans, nstart=25, K.max=20, B=50)

#fviz_gap_stat(gap_stat)

#Nem futott le 4 perc alatt

9.0.3 K=6

Várt: Neighbourhood-ok valamennyire tükröződnek

set.seed(144)
km <- kmeans(total_cluster, centers=5, nstart=25)

#Első lefutáskor az egyik clusterbe 1-3 tagot rak. Ha újrafuttatom a kódot akkor kb 1500-3000 szállás/cluster

summary(km$cluster)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.000   1.000   2.000   2.302   4.000   5.000
total_cluster$id=rownames(total_cluster)
total_cluster$cluster=km$cluster

#Lássuk a clustereket:

plot1 <- ggplot(total_cluster, aes(x=cluster, y=number_of_reviews, fill=cluster, colour=cluster))+geom_point()
plot1

plot2 <- ggplot(total_cluster, aes(x=cluster, y=price, fill=cluster, colour=cluster))+geom_point()
plot2

print(km)
## K-means clustering with 5 clusters of sizes 4288, 3303, 1, 3870, 3
## 
## Cluster means:
##       price number_of_reviews reviews_per_month availability_365
## 1  83.62313          60.27006          2.565273        157.93050
## 2 115.33091          61.44021          2.360890        296.41538
## 3  85.00000         286.00000          3.690000         11.00000
## 4  73.11731          51.36848          2.557943         73.90594
## 5  66.00000          66.33333          2.903333        142.33333
##   host_listings_count accommodates bathrooms bedrooms     beds maximum_nights
## 1           26.130364     3.359375  1.235424 1.345382 2.011894       90.35168
## 2           14.652740     3.897972  1.399485 1.680593 2.340902     1116.10051
## 3            5.000000     4.000000  1.000000 1.000000 2.000000   100000.00000
## 4            7.833592     3.533592  1.298191 1.396382 2.048837     1112.07649
## 5            6.333333     3.333333  1.166667 1.000000 1.333333    16666.66667
##   review_scores_rating review_scores_checkin review_scores_accuracy
## 1             93.26726              9.698461               9.608442
## 2             92.46866              9.633969               9.529216
## 3             95.00000             10.000000              10.000000
## 4             93.13928              9.678295               9.594315
## 5             96.66667              9.666667              10.000000
##   review_scores_cleanliness review_scores_communication review_scores_location
## 1                  9.468284                    9.737873               9.705224
## 2                  9.431426                    9.640932               9.692098
## 3                  9.000000                   10.000000              10.000000
## 4                  9.432041                    9.706202               9.723514
## 5                 10.000000                   10.000000              10.000000
##   review_scores_value availability_30
## 1            9.294543        6.735075
## 2            9.210112        7.888586
## 3            9.000000        3.000000
## 4            9.262016        5.950129
## 5            9.666667        2.333333
## 
## Clustering vector:
##     [1] 1 2 2 1 1 1 1 1 1 1 1 2 4 1 1 4 1 1 1 1 1 1 1 2 1 1 1 2 1 2 2 4 1 1 2 1
##    [37] 1 1 2 2 4 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 4 1 1 1 1 1 1 1 1 4 4 1 1 1 2 1
##    [73] 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1
##   [109] 1 1 1 1 2 1 1 4 1 1 2 2 1 1 1 1 2 1 1 1 2 2 4 1 2 2 1 4 2 2 2 1 1 2 1 4
##   [145] 1 1 1 1 2 1 1 1 4 4 2 1 4 1 1 4 2 1 1 2 1 2 1 1 1 4 1 4 1 2 1 1 2 1 1 1
##   [181] 2 2 1 2 2 1 1 4 1 2 2 1 1 1 2 2 1 2 1 1 2 1 1 1 1 2 1 1 1 2 2 2 1 1 2 1
##   [217] 1 2 2 1 1 1 2 1 2 1 1 2 1 1 1 4 2 2 2 1 1 1 2 1 1 1 2 2 2 2 2 2 1 1 4 2
##   [253] 2 4 1 1 1 2 1 2 2 1 1 1 1 4 2 2 4 1 1 1 1 1 1 1 1 1 1 1 4 2 1 2 1 2 2 1
##   [289] 2 1 1 4 4 2 4 1 1 1 2 4 2 1 4 1 2 1 1 1 1 1 1 1 1 1 1 1 1 4 4 2 1 1 1 1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 1 1 1 4 4 4 2 4 4 2
## [11089] 2 4 1 1 4 2 2 1 4 1 2 2 2 1 4 4 2 4 4 4 4 4 4 4 1 1 4 4 1 1 1 1 1 1 4 1
## [11125] 2 4 1 4 4 2 1 4 2 1 1 4 1 2 1 2 4 4 1 4 1 4 4 4 1 4 4 4 4 1 2 4 4 4 4 4
## [11161] 4 4 4 1 4 1 1 4 4 4 1 2 4 1 1 1 1 1 1 2 1 1 4 2 2 4 4 4 4 1 1 4 2 1 4 4
## [11197] 2 4 4 1 1 4 4 4 4 1 4 2 4 4 1 1 1 4 4 4 1 1 1 1 4 1 4 4 4 1 1 1 1 2 1 4
## [11233] 2 1 2 1 1 4 2 1 2 1 4 1 4 4 4 1 4 2 2 2 1 2 1 1 2 1 1 2 4 1 1 4 4 1 4 4
## [11269] 1 1 4 1 1 4 1 4 4 1 1 4 4 4 4 1 4 1 4 1 4 4 2 2 2 2 2 4 1 2 1 1 1 1 1 1
## [11305] 1 4 2 1 4 1 1 2 1 1 1 4 2 2 4 4 2 4 4 4 1 4 4 4 1 1 1 4 4 4 4 4 1 1 1 4
## [11341] 1 1 4 1 1 2 4 4 2 4 1 1 1 4 1 4 4 4 1 1 1 1 4 2 2 4 4 1 1 1 4 1 1 2 1 1
## [11377] 1 2 4 4 4 1 1 1 4 4 1 4 4 1 1 1 4 4 1 2 1 1 1 4 1 1 2 1 4 1 1 1 4 4 1 4
## [11413] 4 4 4 1 1 4 4 1 4 4 1 1 1 2 1 2 4 2 4 2 1 1 1 1 2 1 1 4 4 1 4 2 2 1 2 4
## [11449] 2 4 2 4 1 4 1 1 1 2 4 2 4 1 1 2 2
## 
## Within cluster sum of squares by cluster:
## [1] 272547947 536900885         0  55139612 266709750
##  (between_SS / total_SS =  92.3 %)
## 
## Available components:
## 
## [1] "cluster"      "centers"      "totss"        "withinss"     "tot.withinss"
## [6] "betweenss"    "size"         "iter"         "ifault"
#Mindegyik clusterről elmonfható valami (pl árkategória, host_listings_count, number_of reviews)

A két plotoknál próbáltam ár/érékelés, ár/értékelések száma stb. scatterplotot, de (1) az outlierek miatt (2) a sok hasonló érték miatt nagyon zavarosak lettek:

plot1 <- ggplot(total_cluster, aes(x=price, y=number_of_reviews, fill=cluster, colour=cluster))+geom_point()+facet_wrap(vars(cluster), scales="free")
plot1

plot2 <- ggplot(total_cluster, aes(x=price, y=accommodates, fill=cluster, colour=cluster))+geom_point()+facet_wrap(vars(cluster), scales="free")
plot2

plot3 <- ggplot(total_cluster, aes(x=price, y=review_scores_rating, fill=cluster, colour=cluster))+geom_point()+facet_wrap(vars(cluster), scales="free")
plot3

Nézzük működik-e a neighbourhoodokra

total_n <- total[, c("neighbourhood_group","id" )]
total_n <- unique(total_n)

total_cluster <- total_cluster[, id:=as.numeric(id)]

neighb <- merge(total_n, total_cluster, by="id")

plot3 <- ggplot(neighb, aes(x=cluster, y=price, fill=neighbourhood_group, colour=neighbourhood_group))+geom_point()
plot3

plot4 <- ggplot(neighb, aes(x=cluster, fill=neighbourhood_group))+geom_histogram(bins=5, show.legend = FALSE)+facet_wrap(vars(neighbourhood_group), scales="free")
plot4

Mit tudunk ezek alapján?

-nem különülnek el élesen a szomszédságok csak clusterezés alapján (lehet egyébként sem annyira, legalábbis nem a 18 változó) -18 attribútum alapján nem tud az R nagyon karakteres clastereket létrehozni -kiemelkedő a km summary-ban mint átlagok -> ár, értékelések száma, host/listings

Ha k=21 cluster:

km <- kmeans(total_cluster, centers=10, nstart=25)
## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)

## Warning: Quick-TRANSfer stage steps exceeded maximum (= 573250)
#Hibaüzenet, képtelen lefuttatni

-Clusterezésnél térképkkordináták bevonása: pl. milyen közel van egy hasonló szállás (hatással lehet az árra)